<%@ tag isELIgnored="false" pageEncoding="UTF-8" description="DataGrid" body-content="empty" %>
<%@ attribute name="data" type="java.util.Collection" required="true" description="数据对象集合(对象Collection)" %>
<%@ attribute name="properties" type="java.lang.String" required="true" description="','分隔属性列表" %>
<%@ attribute name="titles" type="java.lang.String" required="false" description="标题" %>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

<%--
  ~ Copyright (c) 2005, 2014 vacoor
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  --%>

<%-- 剔除空格并切割, 不使用forToken --%>
<c:set var="properties" value="${fn:split(fn:replace(properties, ' ', ''), ',')}"/>

<table class="table table-bordered table-striped table-hover table-condensed">
    <c:if test="${titles != null}">
        <thead>
        <tr>
            <c:forEach var="prop" items="${fn:split(fn:replace(titles, ' ', ''), ',')}">
                <%--<th>${prop}</th>--%>
                <%--<td class="text-left">${prop}</td>--%>
                <th><a href="javascript:;">${prop}</a></th>
            </c:forEach>
        </tr>
        </thead>
    </c:if>
    <c:if test="${data != null}">
        <tbody>
        <c:forEach var="item" items="${data}">
            <tr>
                <c:forEach var="prop" items="${properties}">
                    <td class="text-left">${item[prop]}</td>
                </c:forEach>
            </tr>
        </c:forEach>
        </tbody>
    </c:if>
</table>

